//头文件
#include <hiredis/hiredis.h>
#include <cstdio>
int main()
{
	//连接数据库
	redisContext *c = redisConnect("127.0.0.1", 6379);
	if (c == NULL || c->err) 
	{
    	if (c) 
    	{
        	printf("Error: %s\n", c->errstr);
        	// handle error
    	} else 
    	{
        printf("Can't allocate redis context\n");
    	}
	}
	
	redisReply *reply;
	/*login*/
   	reply = (redisReply *)redisCommand(c,"AUTH aaa111");
   	freeReplyObject(reply);
   	
   	/* PING server */
   	reply = (redisReply *)redisCommand(c,"PING");
   	printf("PING: %s\n", reply->str);
   	freeReplyObject(reply);
   	return 0;
}
